package com.gk.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.eight.pojo.TbUserCoupon;
import com.eight.pojo.UserCharge;
import com.gk.service.TbUserCouponService;
import com.gk.service.UserChargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.eight.pojo.UserCharge;
import com.gk.service.UserChargeService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 客户和优惠卷控制层
 * @author: GK
 * @date: 2023/3/6 10:23
 * @version:No1.0
 */
@RestController
@RequestMapping("customer/userCharge/")
public class UserChargeController {


    @Autowired
    private TbUserCouponService tbUserCouponService;
    @Autowired
    private UserChargeService userChargeService;




    /**
     * 根据账号查询账号所拥有的优惠卷
     * @param username 账号
     * @return 响应前端
     */
    @GetMapping("selectAllUser/{username}")
    public List<TbUserCoupon> selectAllUser(@PathVariable String username){
        return  tbUserCouponService.selectAllUser(username);
    }

    /**
     * 根据id去查询订单状态
     * @param id 充值订单的id
     * @return 查询的结果
     */
    @GetMapping("selectChargeOrder/{id}")
    public UserCharge selectChargeOrder(@PathVariable String id){
        return userChargeService.getOne(new QueryWrapper<UserCharge>().eq("serilcode", id));
    }




    @GetMapping("upStatus/{serilcode}/{statu}")
    public int upStatus(@PathVariable String serilcode,@PathVariable Integer statu){
        return userChargeService.upStatus(serilcode,statu);
    }

}
